﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Backend
{
    public class Program
    {
        static void Main(string[] args)
        {
            
        }

        /// <summary>
        /// Method to test database connection
        /// </summary>
        /// 
        DBConnect dbconn = new DBConnect();

        public bool DBTest()
        {
            bool result = dbconn.TestConnection();
            return result;
        }
        

        /// <summary>
        /// Methods to return data from Customer class
        /// </summary>
        /// 
        Customer customer = new Customer();

        public DataTable FindCustomers(string telephone = "", string fullName = "", int brandID = 0)
        {
            return customer.List(telephone, fullName, brandID);
        }

        public string[] GetCustomerInfo(int cid)
        {
            string[] returnArray = customer.GetInfo(cid);

            return returnArray;
        }

        public bool UpdateCustomer(int cid, string fullName, string address, int zipcode, int telephone, string email)
        {
            bool result = customer.Update(cid, fullName, address, zipcode, telephone, email);

            return result;
        }

        public void CreateCustomer(string fullName, string address, int zipcode, int telephone, string email, out bool result, out int clientID)
        {
            customer.Create(fullName, address, zipcode, telephone, email, out result, out clientID);
        }

        /// <summary>
        /// Methods to return data from Brand class
        /// </summary>
        /// 
        Brand brand = new Brand();

        public DataTable ListBrands(string name = "")
        {
            return brand.List(name);
        }

        public string FindBrand(string bid)
        {
            return brand.Find(bid);
        }

        public bool CreateBrand(string brandName)
        {
            bool result = brand.Create(brandName);
            return result;
        }

        public bool UpdateBrand(int brandID, string brandName)
        {
            bool result = brand.Update(brandID, brandName);
            return result;
        }

        public bool RemoveBrand(int brandID)
        {
            bool result = brand.Remove(brandID);
            return result;
        }

        /// <summary>
        /// Methods to return data from Scooter class
        /// </summary>
        ///
        Scooter scooter = new Scooter();

        public DataTable FindScooters(int cid)
        {
            return scooter.List(cid);
        }

        public bool CreateScooter(string vin, int cid, string registration, int bid)
        {
            bool result = scooter.Create(vin, cid, registration, bid);
            return result;
        }

        public bool UpdateScooter(string vin, int cid, string registration, int bid)
        {
            bool result = scooter.Update(vin, cid, registration, bid);
            return result;
        }

        public bool RemoveScooter(string vin)
        {
            bool result = scooter.Remove(vin);
            return result;
        }

        public string[] GetScooterInfo(string vin)
        {
            string[] returnArray = scooter.GetInfo(vin);

            return returnArray;
        }

        /// <summary>
        /// Methods to return data from Employee class
        /// </summary>
        /// 
        Employee employee = new Employee();

        public DataTable ListEmployees()
        {
            return employee.List();
        }

        public string[] GetEmployeeInfo(int eid)
        {
            string[] returnArray = employee.GetInfo(eid);
            return returnArray;
        }

        public bool UpdateEmployee(int eid, string fullName, string initials)
        {
            bool result = employee.Update(eid, fullName, initials);
            return result;
        }

        public void CreateEmployee(string fullName, string initials, out bool result, out int eid)
        {
            employee.Create(fullName, initials, out result, out eid);
        }

        public bool RemoveEmployee(int eid)
        {
            bool result = employee.Remove(eid);
            return result;
        }

        public DataTable ListSpecialities(int eid)
        {
            return employee.Specialities(eid);
        }

        public bool AddSpeciality(int eid, int bid)
        {
            bool result = employee.AddSpeciality(eid, bid);
            return result;
        }

        public bool RemoveSpeciality(int eid, int bid)
        {
            bool result = employee.RemoveSpeciality(eid, bid);
            return result;
        }

        /// <summary>
        /// Methods to return data from Order class
        /// </summary>
        /// 

        Order order = new Order();

        public DataTable FindOrders(string telephone = "", string fullName = "", int mechanic = 0)
        {
            return order.Find(telephone, fullName, mechanic);
        }

        public void CreateOrder(int cid, int eid, string date, out bool result, out int orderID)
        {
            order.Create(cid, eid, date, out result, out orderID);
        }

        public bool UpdateOrder(int oid, int eid, string smsnotification, string status)
        {
            bool result = order.Update(oid, eid, smsnotification, status);
            return result;
        }

        public bool OrderScooterAdd(int oid, string vin)
        {
            bool result = order.AddScooter(oid, vin);
            return result;
        }

        public bool OrderScooterRemove(int oid, string vin)
        {
            bool result = order.RemoveScooter(oid, vin);
            return result;
        }

        public void OrderProductAdd(int oid, int pid, string productPrice, int quantity, out bool result, out int olid)
        {
            order.AddProduct(oid, pid, productPrice, quantity, out result, out olid);
        }

        public bool OrderProductRemove(int orderID, int olid, string totalprice)
        {
            bool result = order.RemoveProduct(orderID, olid, totalprice);
            return result;
        }

        public DataTable OrderScooterList(int oid)
        {
            return order.Scooters(oid);
        }

        public DataTable ListOrders(int cid)
        {
            return order.List(cid);
        }

        public string LastOrder(string cid)
        {
            string[] result = order.Last(cid);
            return result[1];
        }

        public string[] GetOrderInfo(int oid)
        {
            string[] returnArray = order.GetInfo(oid);

            return returnArray;
        }

        public DataTable GetOrderlines(int oid)
        {
            return order.GetOrderlines(oid);
        }

        public string[] GetOrderlineInfo(int olid)
        {
            string[] returnArray = order.GetOrderlineInfo(olid);

            return returnArray;
        }

        /// <summary>
        /// Methods to return data from Group class
        /// </summary>
        /// 

        Group group = new Group();

        public DataTable ListGroups()
        {
            return group.List();
        }

        public void CreateGroup(string name, out bool result, out int gid)
        {
            group.Create(name, out result, out gid);
        }

        public bool RemoveGroup(int gid)
        {
            bool result = group.Remove(gid);
            return result;
        }

        public bool UpdateGroup(int gid, string name)
        {
            bool result = group.Update(gid, name);
            return result;
        }

        /// <summary>
        /// Methods to return data from Product class
        /// </summary>
        /// 

        Product product = new Product();

        public DataTable ListProducts(int gid, string searchWord = "")
        {
            return product.List(gid, searchWord);
        }

        public bool RemoveAllProducts(int gid)
        {
            bool result = product.RemoveAll(gid);
            return result;
        }

        public void CreateProduct(int gid, string productName, string productPrice, string productOffer, int productStock, string productWord, out bool result, out int productID)
        {
            product.Create(gid, productName, productPrice, productOffer, productStock, productWord, out result, out productID);
        }

        public bool UpdateProduct(int pid, string productName, string productPrice, string productOffer, int productStock, string productWord)
        {
            bool result = product.Update(pid, productName, productPrice, productOffer, productStock, productWord);
            return result;
        }

        public bool RemoveProduct(int pid)
        {
            bool result = product.Remove(pid);
            return result;
        }

        public string[] GetProductInfo(int pid)
        {
            string[] returnArray = product.GetInfo(pid);

            return returnArray;
        }

        /// <summary>
        /// Methods to return data from Invoice class
        /// </summary>
        /// 
        Invoice invoice = new Invoice();

        public DataTable FindInvoices(string telephone = "", string fullName = "", int mechanic = 0)
        {
            return invoice.Find(telephone, fullName, mechanic);
        }

        public string GetInvoice(int orderID)
        {
            string result = invoice.Get(orderID);
            return result;
        }

        public string PrintInvoice(int orderID, string[] arrInvoice)
        {
            string result = invoice.Print(orderID, arrInvoice);
            return result;
        }
    }
}
